import {
  ApiGetDagErrorResponseDto,
  DagTaskStatusEnum
} from '@/services/bussiness/Task/task.api.dto'
import { GraphSeriesOption } from 'echarts/charts'
import { InferArray } from '@/services/uitls/type.util'

/** ------------------------------------------------- dag 图表相关数据结构 ------------------------------------------------- */

// dag 图表，节点携带的信息
export interface ChartVertexInfoInterface {
  name: string
  taskInfo?: {
    id: number
    taskId: number
  }
}

// dag 图表，边携带的信息
export interface ChartEdgeInfoInterface {}

// dag 图表，节点类型
export type ChartNodeType = InferArray<GraphSeriesOption['nodes']> & ChartVertexInfoInterface

// dag 图表，边类型
export type ChartEdgeType = InferArray<GraphSeriesOption['edges']> & ChartEdgeInfoInterface

/** ------------------------------------------------- log 相关数据结构 ------------------------------------------------- */
export interface OperateVertexInterface {
  type: 'add' | 'delete'
  dagName: string
  taskName: string
}

export interface OperateEdgeInterface {
  type: 'add' | 'delete'
  dagName: string
  taskName: string
  nextTaskName: string
}

export interface OperateStackInterface {
  vertexList: Array<OperateVertexInterface>
  edgeList: Array<OperateEdgeInterface>
}

export type OperateVertexLogInfoType = Pick<OperateVertexInterface, 'taskName'>

export type OperateEdgeLogInfoType = Pick<OperateEdgeInterface, 'taskName' | 'nextTaskName'>

/** ------------------------------------------------- 生命周期 ------------------------------------------------- */
export interface LifeCycleMethodsInterface {
  afterInit: (error: ApiGetDagErrorResponseDto | void) => void
}

/** ------------------------------------------------- 生命周期 ------------------------------------------------- */
// 设置节点状态所需数据
export interface SetNodeStatusParams {
  taskId: number
  status: DagTaskStatusEnum
}
